home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / nfsmount / nfs_prot_xdr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-14  |  7.9 KB  |  586 lines

  1. #include <rpc/rpc.h>
  2. #include "nfs_prot.h"
  3.  
  4.  
  5. bool_t
  6. xdr_nfsstat(xdrs, objp)
  7.     XDR *xdrs;
  8.     nfsstat *objp;
  9. {
  10.     if (!xdr_enum(xdrs, (enum_t *)objp)) {
  11.         return (FALSE);
  12.     }
  13.     return (TRUE);
  14. }
  15.  
  16.  
  17.  
  18.  
  19. bool_t
  20. xdr_ftype(xdrs, objp)
  21.     XDR *xdrs;
  22.     ftype *objp;
  23. {
  24.     if (!xdr_enum(xdrs, (enum_t *)objp)) {
  25.         return (FALSE);
  26.     }
  27.     return (TRUE);
  28. }
  29.  
  30.  
  31.  
  32.  
  33. bool_t
  34. xdr_nfs_fh(xdrs, objp)
  35.     XDR *xdrs;
  36.     nfs_fh *objp;
  37. {
  38.     if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) {
  39.         return (FALSE);
  40.     }
  41.     return (TRUE);
  42. }
  43.  
  44.  
  45.  
  46.  
  47. bool_t
  48. xdr_nfstime(xdrs, objp)
  49.     XDR *xdrs;
  50.     nfstime *objp;
  51. {
  52.     if (!xdr_u_int(xdrs, &objp->seconds)) {
  53.         return (FALSE);
  54.     }
  55.     if (!xdr_u_int(xdrs, &objp->useconds)) {
  56.         return (FALSE);
  57.     }
  58.     return (TRUE);
  59. }
  60.  
  61.  
  62.  
  63.  
  64. bool_t
  65. xdr_fattr(xdrs, objp)
  66.     XDR *xdrs;
  67.     fattr *objp;
  68. {
  69.     if (!xdr_ftype(xdrs, &objp->type)) {
  70.         return (FALSE);
  71.     }
  72.     if (!xdr_u_int(xdrs, &objp->mode)) {
  73.         return (FALSE);
  74.     }
  75.     if (!xdr_u_int(xdrs, &objp->nlink)) {
  76.         return (FALSE);
  77.     }
  78.     if (!xdr_u_int(xdrs, &objp->uid)) {
  79.         return (FALSE);
  80.     }
  81.     if (!xdr_u_int(xdrs, &objp->gid)) {
  82.         return (FALSE);
  83.     }
  84.     if (!xdr_u_int(xdrs, &objp->size)) {
  85.         return (FALSE);
  86.     }
  87.     if (!xdr_u_int(xdrs, &objp->blocksize)) {
  88.         return (FALSE);
  89.     }
  90.     if (!xdr_u_int(xdrs, &objp->rdev)) {
  91.         return (FALSE);
  92.     }
  93.     if (!xdr_u_int(xdrs, &objp->blocks)) {
  94.         return (FALSE);
  95.     }
  96.     if (!xdr_u_int(xdrs, &objp->fsid)) {
  97.         return (FALSE);
  98.     }
  99.     if (!xdr_u_int(xdrs, &objp->fileid)) {
  100.         return (FALSE);
  101.     }
  102.     if (!xdr_nfstime(xdrs, &objp->atime)) {
  103.         return (FALSE);
  104.     }
  105.     if (!xdr_nfstime(xdrs, &objp->mtime)) {
  106.         return (FALSE);
  107.     }
  108.     if (!xdr_nfstime(xdrs, &objp->ctime)) {
  109.         return (FALSE);
  110.     }
  111.     return (TRUE);
  112. }
  113.  
  114.  
  115.  
  116.  
  117. bool_t
  118. xdr_sattr(xdrs, objp)
  119.     XDR *xdrs;
  120.     sattr *objp;
  121. {
  122.     if (!xdr_u_int(xdrs, &objp->mode)) {
  123.         return (FALSE);
  124.     }
  125.     if (!xdr_u_int(xdrs, &objp->uid)) {
  126.         return (FALSE);
  127.     }
  128.     if (!xdr_u_int(xdrs, &objp->gid)) {
  129.         return (FALSE);
  130.     }
  131.     if (!xdr_u_int(xdrs, &objp->size)) {
  132.         return (FALSE);
  133.     }
  134.     if (!xdr_nfstime(xdrs, &objp->atime)) {
  135.         return (FALSE);
  136.     }
  137.     if (!xdr_nfstime(xdrs, &objp->mtime)) {
  138.         return (FALSE);
  139.     }
  140.     return (TRUE);
  141. }
  142.  
  143.  
  144.  
  145.  
  146. bool_t
  147. xdr_filename(xdrs, objp)
  148.     XDR *xdrs;
  149.     filename *objp;
  150. {
  151.     if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
  152.         return (FALSE);
  153.     }
  154.     return (TRUE);
  155. }
  156.  
  157.  
  158.  
  159.  
  160. bool_t
  161. xdr_nfspath(xdrs, objp)
  162.     XDR *xdrs;
  163.     nfspath *objp;
  164. {
  165.     if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
  166.         return (FALSE);
  167.     }
  168.     return (TRUE);
  169. }
  170.  
  171.  
  172.  
  173.  
  174. bool_t
  175. xdr_attrstat(xdrs, objp)
  176.     XDR *xdrs;
  177.     attrstat *objp;
  178. {
  179.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  180.         return (FALSE);
  181.     }
  182.     switch (objp->status) {
  183.     case NFS_OK:
  184.         if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) {
  185.             return (FALSE);
  186.         }
  187.         break;
  188.     }
  189.     return (TRUE);
  190. }
  191.  
  192.  
  193.  
  194.  
  195. bool_t
  196. xdr_sattrargs(xdrs, objp)
  197.     XDR *xdrs;
  198.     sattrargs *objp;
  199. {
  200.     if (!xdr_nfs_fh(xdrs, &objp->file)) {
  201.         return (FALSE);
  202.     }
  203.     if (!xdr_sattr(xdrs, &objp->attributes)) {
  204.         return (FALSE);
  205.     }
  206.     return (TRUE);
  207. }
  208.  
  209.  
  210.  
  211.  
  212. bool_t
  213. xdr_diropargs(xdrs, objp)
  214.     XDR *xdrs;
  215.     diropargs *objp;
  216. {
  217.     if (!xdr_nfs_fh(xdrs, &objp->dir)) {
  218.         return (FALSE);
  219.     }
  220.     if (!xdr_filename(xdrs, &objp->name)) {
  221.         return (FALSE);
  222.     }
  223.     return (TRUE);
  224. }
  225.  
  226.  
  227.  
  228.  
  229. bool_t
  230. xdr_diropokres(xdrs, objp)
  231.     XDR *xdrs;
  232.     diropokres *objp;
  233. {
  234.     if (!xdr_nfs_fh(xdrs, &objp->file)) {
  235.         return (FALSE);
  236.     }
  237.     if (!xdr_fattr(xdrs, &objp->attributes)) {
  238.         return (FALSE);
  239.     }
  240.     return (TRUE);
  241. }
  242.  
  243.  
  244.  
  245.  
  246. bool_t
  247. xdr_diropres(xdrs, objp)
  248.     XDR *xdrs;
  249.     diropres *objp;
  250. {
  251.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  252.         return (FALSE);
  253.     }
  254.     switch (objp->status) {
  255.     case NFS_OK:
  256.         if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) {
  257.             return (FALSE);
  258.         }
  259.         break;
  260.     }
  261.     return (TRUE);
  262. }
  263.  
  264.  
  265.  
  266.  
  267. bool_t
  268. xdr_readlinkres(xdrs, objp)
  269.     XDR *xdrs;
  270.     readlinkres *objp;
  271. {
  272.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  273.         return (FALSE);
  274.     }
  275.     switch (objp->status) {
  276.     case NFS_OK:
  277.         if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) {
  278.             return (FALSE);
  279.         }
  280.         break;
  281.     }
  282.     return (TRUE);
  283. }
  284.  
  285.  
  286.  
  287.  
  288. bool_t
  289. xdr_readargs(xdrs, objp)
  290.     XDR *xdrs;
  291.     readargs *objp;
  292. {
  293.     if (!xdr_nfs_fh(xdrs, &objp->file)) {
  294.         return (FALSE);
  295.     }
  296.     if (!xdr_u_int(xdrs, &objp->offset)) {
  297.         return (FALSE);
  298.     }
  299.     if (!xdr_u_int(xdrs, &objp->count)) {
  300.         return (FALSE);
  301.     }
  302.     if (!xdr_u_int(xdrs, &objp->totalcount)) {
  303.         return (FALSE);
  304.     }
  305.     return (TRUE);
  306. }
  307.  
  308.  
  309.  
  310.  
  311. bool_t
  312. xdr_readokres(xdrs, objp)
  313.     XDR *xdrs;
  314.     readokres *objp;
  315. {
  316.     if (!xdr_fattr(xdrs, &objp->attributes)) {
  317.         return (FALSE);
  318.     }
  319.     if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
  320.         return (FALSE);
  321.     }
  322.     return (TRUE);
  323. }
  324.  
  325.  
  326.  
  327.  
  328. bool_t
  329. xdr_readres(xdrs, objp)
  330.     XDR *xdrs;
  331.     readres *objp;
  332. {
  333.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  334.         return (FALSE);
  335.     }
  336.     switch (objp->status) {
  337.     case NFS_OK:
  338.         if (!xdr_readokres(xdrs, &objp->readres_u.reply)) {
  339.             return (FALSE);
  340.         }
  341.         break;
  342.     }
  343.     return (TRUE);
  344. }
  345.  
  346.  
  347.  
  348.  
  349. bool_t
  350. xdr_writeargs(xdrs, objp)
  351.     XDR *xdrs;
  352.     writeargs *objp;
  353. {
  354.     if (!xdr_nfs_fh(xdrs, &objp->file)) {
  355.         return (FALSE);
  356.     }
  357.     if (!xdr_u_int(xdrs, &objp->beginoffset)) {
  358.         return (FALSE);
  359.     }
  360.     if (!xdr_u_int(xdrs, &objp->offset)) {
  361.         return (FALSE);
  362.     }
  363.     if (!xdr_u_int(xdrs, &objp->totalcount)) {
  364.         return (FALSE);
  365.     }
  366.     if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
  367.         return (FALSE);
  368.     }
  369.     return (TRUE);
  370. }
  371.  
  372.  
  373.  
  374.  
  375. bool_t
  376. xdr_createargs(xdrs, objp)
  377.     XDR *xdrs;
  378.     createargs *objp;
  379. {
  380.     if (!xdr_diropargs(xdrs, &objp->where)) {
  381.         return (FALSE);
  382.     }
  383.     if (!xdr_sattr(xdrs, &objp->attributes)) {
  384.         return (FALSE);
  385.     }
  386.     return (TRUE);
  387. }
  388.  
  389.  
  390.  
  391.  
  392. bool_t
  393. xdr_renameargs(xdrs, objp)
  394.     XDR *xdrs;
  395.     renameargs *objp;
  396. {
  397.     if (!xdr_diropargs(xdrs, &objp->from)) {
  398.         return (FALSE);
  399.     }
  400.     if (!xdr_diropargs(xdrs, &objp->to)) {
  401.         return (FALSE);
  402.     }
  403.     return (TRUE);
  404. }
  405.  
  406.  
  407.  
  408.  
  409. bool_t
  410. xdr_linkargs(xdrs, objp)
  411.     XDR *xdrs;
  412.     linkargs *objp;
  413. {
  414.     if (!xdr_nfs_fh(xdrs, &objp->from)) {
  415.         return (FALSE);
  416.     }
  417.     if (!xdr_diropargs(xdrs, &objp->to)) {
  418.         return (FALSE);
  419.     }
  420.     return (TRUE);
  421. }
  422.  
  423.  
  424.  
  425.  
  426. bool_t
  427. xdr_symlinkargs(xdrs, objp)
  428.     XDR *xdrs;
  429.     symlinkargs *objp;
  430. {
  431.     if (!xdr_diropargs(xdrs, &objp->from)) {
  432.         return (FALSE);
  433.     }
  434.     if (!xdr_nfspath(xdrs, &objp->to)) {
  435.         return (FALSE);
  436.     }
  437.     if (!xdr_sattr(xdrs, &objp->attributes)) {
  438.         return (FALSE);
  439.     }
  440.     return (TRUE);
  441. }
  442.  
  443.  
  444.  
  445.  
  446. bool_t
  447. xdr_nfscookie(xdrs, objp)
  448.     XDR *xdrs;
  449.     nfscookie objp;
  450. {
  451.     if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
  452.         return (FALSE);
  453.     }
  454.     return (TRUE);
  455. }
  456.  
  457.  
  458.  
  459.  
  460. bool_t
  461. xdr_readdirargs(xdrs, objp)
  462.     XDR *xdrs;
  463.     readdirargs *objp;
  464. {
  465.     if (!xdr_nfs_fh(xdrs, &objp->dir)) {
  466.         return (FALSE);
  467.     }
  468.     if (!xdr_nfscookie(xdrs, objp->cookie)) {
  469.         return (FALSE);
  470.     }
  471.     if (!xdr_u_int(xdrs, &objp->count)) {
  472.         return (FALSE);
  473.     }
  474.     return (TRUE);
  475. }
  476.  
  477.  
  478.  
  479.  
  480. bool_t
  481. xdr_entry(xdrs, objp)
  482.     XDR *xdrs;
  483.     entry *objp;
  484. {
  485.     if (!xdr_u_int(xdrs, &objp->fileid)) {
  486.         return (FALSE);
  487.     }
  488.     if (!xdr_filename(xdrs, &objp->name)) {
  489.         return (FALSE);
  490.     }
  491.     if (!xdr_nfscookie(xdrs, objp->cookie)) {
  492.         return (FALSE);
  493.     }
  494.     if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), xdr_entry)) {
  495.         return (FALSE);
  496.     }
  497.     return (TRUE);
  498. }
  499.  
  500.  
  501.  
  502.  
  503. bool_t
  504. xdr_dirlist(xdrs, objp)
  505.     XDR *xdrs;
  506.     dirlist *objp;
  507. {
  508.     if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), xdr_entry)) {
  509.         return (FALSE);
  510.     }
  511.     if (!xdr_bool(xdrs, &objp->eof)) {
  512.         return (FALSE);
  513.     }
  514.     return (TRUE);
  515. }
  516.  
  517.  
  518.  
  519.  
  520. bool_t
  521. xdr_readdirres(xdrs, objp)
  522.     XDR *xdrs;
  523.     readdirres *objp;
  524. {
  525.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  526.         return (FALSE);
  527.     }
  528.     switch (objp->status) {
  529.     case NFS_OK:
  530.         if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) {
  531.             return (FALSE);
  532.         }
  533.         break;
  534.     }
  535.     return (TRUE);
  536. }
  537.  
  538.  
  539.  
  540.  
  541. bool_t
  542. xdr_statfsokres(xdrs, objp)
  543.     XDR *xdrs;
  544.     statfsokres *objp;
  545. {
  546.     if (!xdr_u_int(xdrs, &objp->tsize)) {
  547.         return (FALSE);
  548.     }
  549.     if (!xdr_u_int(xdrs, &objp->bsize)) {
  550.         return (FALSE);
  551.     }
  552.     if (!xdr_u_int(xdrs, &objp->blocks)) {
  553.         return (FALSE);
  554.     }
  555.     if (!xdr_u_int(xdrs, &objp->bfree)) {
  556.         return (FALSE);
  557.     }
  558.     if (!xdr_u_int(xdrs, &objp->bavail)) {
  559.         return (FALSE);
  560.     }
  561.     return (TRUE);
  562. }
  563.  
  564.  
  565.  
  566.  
  567. bool_t
  568. xdr_statfsres(xdrs, objp)
  569.     XDR *xdrs;
  570.     statfsres *objp;
  571. {
  572.     if (!xdr_nfsstat(xdrs, &objp->status)) {
  573.         return (FALSE);
  574.     }
  575.     switch (objp->status) {
  576.     case NFS_OK:
  577.         if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) {
  578.             return (FALSE);
  579.         }
  580.         break;
  581.     }
  582.     return (TRUE);
  583. }
  584.  
  585.  
  586.